<?php
class Arm_Registry_Row{

    private static $_instance = null;

    private  $records = array();
    private  $object;

    public static function getInstance(){
    
        if(is_null(self::$_instance)){
            self::$_instance = new self();
        }
        return self::$_instance;
    }

    public function isRegistred(Zend_Db_Table_Abstract $model,$id){
       
        $id    = (int)$id;
        $model = get_class($model);
       
        if(array_key_exists($model,$this->records)){
            if(array_key_exists($id,$this->records[$model])){
                $this->object = $this->records[$model][$id];
                return true;
            }
        }
        return false;
    }

    public function get(){
        return $this->object;
    }

    public function set(Arm_Db_Table_Row_Abstract $object){
        
        $model = get_class($object->_class_table);
        $id    = $object->key();

        if(!array_key_exists($model,$this->records)) $this->records[$model] = array();
        $this->records[$model][$id] = $object;
    }
}
